<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>
<body>
        <div id="app">
            <h1>{{count}}</h1>
            <!-- v-on简写为@ -->
            <button @click="count++">++</button>
            <button  @click="add">--</button>
            <button @click="pop($event)"></button>
            <button @click = 'douber(5,$event)'></button>
        </div>
        <script>
            const vm = new Vue({
                el:'#app',
                data(){
                   return  {
                    count:0
                   }
                },
                methods:{
                    add(e){
                        console.log(e,'e');
                        //这里的this值的是vue中的实例对象
                        this.count++
                    },
                    //如果在调用函数的时候加入了括号，但是没有加入实参，这个时候打印的e就是undefined,只有加入了$event才能打印出来event对象
                    pop(e){
                        console.log(e,'e1');
                    },
                    douber(n,e){
                        //切记此处要用this.count
                        this.count = this.count +n
                    }
                }
            })
        </script>
</body>
</html>